package com.bc.bcbuyerapihttp.controller;

import com.bc.bcapi.service.T_FeedbackService;
import com.bc.bcbuyerapihttp.common.UserContext;
import com.bc.bcmodel.BuyerUserInfo;
import com.bc.bcmodel.domain.T_User_buyer_infoModel;
import com.bc.bcmodel.domain.T_User_seller_infoModel;
import com.bc.bcmodel.req.FeedBackReq;
import com.bc.commonentity.common.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Name CustomController
 * @Description TODO
 * @Author douhaichao
 * @Date 2018/9/6 13:00
 * @Version 1.0
 **/
@RestController
@RequestMapping(value = "/nologon/marvel/")
@Api(value = "客服相关")
public class CustomController {
    private static final Logger LOGGER = LoggerFactory.getLogger(CustomController.class);

    @Autowired
    T_FeedbackService t_feedbackService;

    @ApiOperation(value = "用户反馈")
    @RequestMapping(value = "feedback", method = RequestMethod.POST)
    public JsonResult feedback(@RequestBody FeedBackReq req) {
        BuyerUserInfo loginInfo = UserContext.getCurrentContext().getLoginInfo();
        if (loginInfo != null) {
            req.setUser_id(loginInfo.getUser_id());
        }
        req.setPlatform(2);
        return t_feedbackService.feedBack(req);
    }

    @ApiOperation("获取当前用户的email")
    @RequestMapping(value = "getemail", method = RequestMethod.GET)
    public JsonResult getEmail() {
        BuyerUserInfo loginInfo = UserContext.getCurrentContext().getLoginInfo();
        JsonResult js = new JsonResult();
        if (loginInfo != null) {
            js.setData(loginInfo.getEmail());
        }
        return js;
    }

}
